/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年2月21日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @Type A20200221_sorttest
 * @Desc
 * @author 52489
 * @date 2020年2月21日
 * @Version V1.0
 */
public class A20200225_sorttest_shell_count {
    public static void main(String[] args) {
        int[] nums = { 10, 6, 3, 8, 33, 27, 66, 9, 7, 88, 20 };
        System.out.println(Arrays.toString(radix(nums)));
        // System.out.println(Arrays.toString(insert(nums)));
        // System.out.println(Arrays.toString(select(nums)));
    }

    /**
     * @param nums
     * @return
     */
    private static int[] radix(int[] nums) {
        int max = nums[0];
        for (int i = 0; i < nums.length; i++) {
            if (max < nums[i]) {
                max = nums[i];
            }
        }

        int weishu = String.valueOf(max).length();
        Queue<Integer> q = new LinkedList<>();

        for (int i = 0; i < weishu; i++) {
            for (int j = 0; j < nums.length; j++) {
                char x = String.valueOf(nums[j]).charAt(0);
            }
        }

        return nums;

    }

    /**
     * @param nums
     * @return
     */
    private static int[] insert(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length - i + 1; j++) {
                if (nums[j] > nums[j + 1]) {
                    int tmp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = tmp;
                }
            }
        }
        return nums;
    }

    /**
     * @param nums
     * @return
     */
    private static int[] shell(int[] nums) {
        for (int step = nums.length / 2; step > 0; step /= 2) {
            for (int i = step; i < nums.length; i += step) {
                int tmp = nums[i];
                int k = i - step;
                while (k >= 0 && nums[k] > tmp) {
                    nums[k + step] = nums[k];
                    k -= step;
                }
                nums[k + step] = tmp;
            }

        }
        return nums;
    }
}
